package com.lxp.modules.gyy.controller;

import com.lxp.common.core.domain.AjaxResult;
import com.lxp.common.core.page.TableDataInfo;
import com.lxp.modules.gyy.domain.ApprovalRequest;
import com.lxp.modules.gyy.domain.vo.AuditParam;
import com.lxp.modules.gyy.service.ApprovalRequestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/gyy/approval")
@Api(tags = "工业云审批接口")
@Slf4j
public class ApprovalRequestController {

    @Resource
    private ApprovalRequestService approvalRequestService;

    @ApiOperation("查询审批")
    @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ApprovalRequest.class)))
    @GetMapping("/list")
    public TableDataInfo list(AuditParam param, TableDataInfo info) {
        return approvalRequestService.pageList(param, info);
    }

    @ApiOperation("查询一条审批")
    @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AjaxResult.class)))
    @GetMapping("/{approvalId}")
    public AjaxResult getOneById(@PathVariable Long approvalId) {
        return approvalRequestService.getOneById(approvalId);
    }
}
